/**
 * @description 基本信息
 * @author wangjianjun
 */

import React, { PureComponent } from 'react';
import { DATA_ENTRY, FormGroup } from '../../../../../comps';
import config from './config';
import moment from 'moment';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
const bondLending = config.bondLending;
const init = config.bondLending.init;
import { connect } from 'dva';
import 'moment/locale/zh-cn';
import investmentTypeData from '../../../../../utils/enumeratedValues/investmentType';
import { calculateFee } from '../../../../../utils/commonFunc';
@Form.create()
@connect(({ exchangeAgreement, bondTrade, buybackOrder, userM: user }) => ({
  exchangeAgreement,
  bondTrade,
  buybackOrder,
  user,
}))
export default class InstructionSend extends PureComponent {
  constructor(props) {
    super(props);
    (this.status = true),
      (this.state = {
        formItem: {},
        orderCategoryData: bondLending.declareType.init, //申报类型默认下拉控制
        originalOrderNumberRequired: false, //原订单号是否必填控制，申报类型不为成交申报时必填
        counterPartyperRequired: true, //交易对手系列必填控制,交易所为上交所时必填
        productGroupDisabled: false, //控制组合产品disable
        orderCategoryDisabled: true, //申报类型disable
        exchangeCodeDisabled: true, //控制交易市场disabled
        orderSideDisabled: true, //控制委托方向disabled
        originalOrderNumberDisabled: false, //原订单号禁用
        lendingFeeDisabled: false, //借贷费用禁止
        reNewDataDisabled: false, //回填时禁用
        counterPartyAccountDisabled: false, //交易对手账号禁用
        counterPartyorgDisabled: false, //交易对手单元禁用
        disabled: true, //控制全局disable
        firstsettlementDate: moment(new Date()),
        totalMoney: null, //借贷总额
        pid: '', //在途外面的id，给后台用
        editId1: '', //修改回填id，发请求要用
        editId2: '', //修改回填id，发请求要用
        Share: 12,
        productShare: 24,
        productMargin: '10px',
        onRef: () => {}, // 本组件的引用
        feeData: {
          //费用自动计算条件
          productId: undefined,
          portfolioid: undefined,
          exchangecode: '101',
          sectype: 'zqjd',
          orderside: undefined,
          timeLimit: undefined,
          pledgedbondsamount: undefined,
          price: undefined,
        },
      });
  }

  componentDidMount() {
    // 父组件对本组件的引用
    this.props.onRef(this);
  }

  UNSAFE_componentWillReceiveProps(nextProps) {
    const {
      form: { getFieldValue, setFieldsValue },
    } = this.formGroupThis.props;
    // 融入：等于质押券面值总和 融出：等于标的债券面值
    const init1 = !this.props.totalMoney1 ? '' : JSON.stringify(this.props.totalMoney1);
    const initN1 = !nextProps.totalMoney1 ? '' : JSON.stringify(nextProps.totalMoney1);
    const init2 = !this.props.totalMoney2 ? '' : JSON.stringify(this.props.totalMoney2);
    const initN2 = !nextProps.totalMoney2 ? '' : JSON.stringify(nextProps.totalMoney2);
    if (init2 != initN2) {
      this.setState(
        {
          totalMoney: nextProps.totalMoney2,
        },
        () => {
          let lendingRate = getFieldValue('lendingRate');
          let totalMoney = this.state.totalMoney;
          let occupationDays = getFieldValue('occupationDays');
          this.calculationLendingFee(lendingRate, totalMoney, occupationDays);
        },
      );
      setFieldsValue({ lendingTotalMoney: nextProps.totalMoney2 });
      this.changeFee('price', nextProps.totalMoney2);
    }

    //详情回填
    if (nextProps.initValue && this.status) {
      this.status = false;
      this.setState({
        orderCategoryData: bondLending.declareType.all,
        formItem: nextProps.initValue,
        totalMoney: nextProps.initValue.lendingeAmount,
        productGroupDisabled: true,
      });
      setFieldsValue({ lendingTotalMoney: nextProps.initValue.lendingeAmount });
      this.changeFee('price', nextProps.initValue.lendingeAmount);
    }

    //修改回填
    if (nextProps.editInitValue && this.status) {
      this.status = false;

      this.reNewPledgeBondData(nextProps.editInitValue.trade16, null, nextProps.editInitValue);
    }
  }

  //费用自动计算
  changeFee = (type, data) => {
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    if (this.props.type == 3 || this.props.type == 4) return; //详情不计算
    setTimeout(() => {
      if (data == undefined) {
        setFieldsValue({ fee: undefined });
        if (type == 'productId') {
          this.setState({ feeData: { ...this.state.feeData, productId: undefined, portfolioid: undefined } });
        } else {
          this.setState({ feeData: { ...this.state.feeData, [type]: undefined } });
        }
      } else {
        this.setState({ feeData: { ...this.state.feeData, [type]: data } }, () => {
          let fee = calculateFee(this.state.feeData);
          fee.then((r) => {
            setFieldsValue({ fee: r });
          });
        });
      }
    }, 100);
  };

  //清空页面
  resetPage = (type) => {
    //清空质押券表内容,清空标的券表内容
    this.props.resetPage();
    this.setState({
      totalMoney: null,
    });
    this.changeFee('price', undefined);
    // 清空持仓和在途
    if (type == '1') {
      this.props.getConfigData('PositionAnalysis', null);
      this.props.getConfigData('RepurchaseInfor', null);
    }

    //促发设置新增按钮disabled 和一些数值传到质押券和标的券组件

    //清空pid
    this.setState({
      pid: '',
    });
  };

  //清空基础信息页面相关的公共参数
  resetField = (type) => {
    const {
      form: { resetFields },
    } = this.formGroupThis.props;
    //清空基础信息页面相关的公共参数
    //   1.不清空组合
    //   2.不清空交易市场,和组合,申报类型，委托方向
    //   3.所有都清空
    if (type == 1) {
      resetFields([
        'orderCategory',
        'exchangeCode',
        'orderSide',
        'originalOrderNumber',
        'counterParty',
        'counterPartyper',
        'counterPartyAccount',
        'counterPartyorg',
        'liquidationSpeed',
        'lendingDays',
        'occupationDays',
        'loanFaceValue',
        'lendingRate',
        'fee',
        'lendingFee',
        'firstsettlementType',
        'settlementType',
        'firstsettlementDate',
        'settlementDate',
        'pledgeExchange',
        'conflictreSolution',
        'creator',
        'remark',
      ]);

      //把默认交易市场和委托方向传到子组件
      this.props.getConfigData('exchangeCode', init.exchangeCode.initValue);
      this.props.getConfigData('orderSide', init.orderSide.initValue);
    }

    if (type == 2) {
      resetFields([
        'originalOrderNumber',
        'counterParty',
        'counterPartyper',
        'fee',
        'counterPartyAccount',
        'counterPartyorg',
        'liquidationSpeed',
        'lendingDays',
        'occupationDays',
        'loanFaceValue',
        'lendingRate',
        'lendingFee',
        'firstsettlementType',
        'settlementType',
        'firstsettlementDate',
        'settlementDate',
        'pledgeExchange',
        'conflictreSolution',
        'creator',
        'remark',
      ]);
    }
    if (type == 3) {
      resetFields([
        'productId',
        'portfolioId',
        'orderCategory',
        'exchangeCode',
        'orderSide',
        'originalOrderNumber',
        'counterParty',
        'counterPartyper',
        'counterPartyAccount',
        'counterPartyorg',
        'liquidationSpeed',
        'lendingDays',
        'occupationDays',
        'loanFaceValue',
        'lendingRate',
        'fee',
        'lendingFee',
        'firstsettlementType',
        'settlementType',
        'firstsettlementDate',
        'settlementDate',
        'pledgeExchange',
        'conflictreSolution',
        'creator',
        'remark',
      ]);
      this.setState({
        reNewDataDisabled: false, //回填时禁用
        productGroupDisabled: false, //控制组合产品disable
      });

      //把默认交易市场和委托方向传到子组件
      this.props.getConfigData('exchangeCode', init.exchangeCode.initValue);
      this.props.getConfigData('orderSide', init.orderSide.initValue);
    }
  };

  //点击在途回购代码 指令基本信息回填
  reNewPledgeBondData = (reNewPledgeBondData, data, editData) => {
    //点击回填 ，标的和 质押券 禁止操作.
    //  this.props.huitian()
    //如果是编辑回填，保存id
    if (editData) {
      this.setState({
        editId1: editData.id,
        editId2: editData.trade16.id,
      });
    }
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;
    this.props.dispatch({
      type: 'exchangeAgreement/save',
      payload: {
        counterparty: [{ id: reNewPledgeBondData.counterParty, name: reNewPledgeBondData.counterPartyName ? reNewPledgeBondData.counterPartyName : null }],
      },
    });

    //如果是簿记编辑进来,需要去请求持仓和在途
    if (this.props.type == '2') {
      let positionParameter = {
        portfolioId: reNewPledgeBondData.portfolioId,
        exchangeCode: reNewPledgeBondData.exchangeCode,
      };
      this.props.getConfigData('PositionAnalysis', positionParameter);

      let repurchaseParameter = {
        portfolioId: reNewPledgeBondData.portfolioId,
        method: '0',
      };
      this.props.getConfigData('RepurchaseInfor', repurchaseParameter);
    }

    setFieldsValue({
      orderCategory: null,
      originalOrderNumber: reNewPledgeBondData.originalOrderNumber,
      // creator:null,
      // remark:null,

      portfolioId: reNewPledgeBondData.portfolioId,
      productId: reNewPledgeBondData.productId,
      exchangeCode: reNewPledgeBondData.exchangeCode,
      orderSide: reNewPledgeBondData.orderSide,

      counterParty: reNewPledgeBondData.counterParty,
      counterPartyper: reNewPledgeBondData.counterPartyper,
      counterPartyAccount: reNewPledgeBondData.counterPartyAccount,
      counterPartyorg: reNewPledgeBondData.counterPartyorg,

      liquidationSpeed: reNewPledgeBondData.liquidationSpeed,
      lendingDays: reNewPledgeBondData.lendingDays,
      occupationDays: reNewPledgeBondData.occupationDays,
      lendingRate: reNewPledgeBondData.lendingRate,

      lendingFee: reNewPledgeBondData.lendingFee,
      firstsettlementType: reNewPledgeBondData.firstsettlementType,
      settlementType: reNewPledgeBondData.settlementType,
      firstsettlementDate: moment(reNewPledgeBondData.firstSettlemenDate),
      settlementDate: moment(reNewPledgeBondData.settlementDate),

      pledgeExchange: reNewPledgeBondData.pledgeExchange,
      conflictreSolution: reNewPledgeBondData.conflictreSolution,
    });

    //券面总额
    this.setState({
      totalMoney: reNewPledgeBondData.lendingeAmount,
      reNewDataDisabled: true,
      disabled: false,
      orderCategoryDisabled: false,
      exchangeCodeDisabled: false,
      orderSideDisabled: false,
    });
    setFieldsValue({ lendingTotalMoney: reNewPledgeBondData.lendingeAmount });

    this.changeFee('price', reNewPledgeBondData.lendingeAmount);
    //申报类型下拉切换
    if (this.props.type == '1') {
      this.setState({
        orderCategoryData: bondLending.declareType.callback,
      });
    }

    //根据申报类型设置对应的disabled和必填
    if (reNewPledgeBondData.orderCategory == '1') {
      this.setState({
        originalOrderNumberRequired: false,
        originalOrderNumberDisabled: true,
        lendingFeeDisabled: true,
      });
    } else if (reNewPledgeBondData.orderCategory == '2') {
      this.setState({
        originalOrderNumberRequired: true,
        originalOrderNumberDisabled: false,
        lendingFeeDisabled: true,
      });
    } else if (reNewPledgeBondData.orderCategory == '3') {
      this.setState({
        originalOrderNumberRequired: true,
        originalOrderNumberDisabled: false,
        lendingFeeDisabled: false,
      });
    }

    //交易所为不同类型时,控制disabled和必填

    if (reNewPledgeBondData.exchangeCode == '101') {
      this.setState({
        counterPartyperRequired: true,
      });
    } else {
      this.setState({
        counterPartyperRequired: false,
        counterPartyAccountDisabled: true,
        counterPartyorgDisabled: true,
      });
    }

    //把交易市场和委托方向传到子组件
    this.props.getConfigData('exchangeCode', reNewPledgeBondData.exchangeCode);
    this.props.getConfigData('orderSide', reNewPledgeBondData.orderSide);

    if (data) {
      this.setState({
        pid: data.idx ? data.idx : '',
      });
    }
  };

  //交易对手搜索
  handleSearch = (value) => {
    if (value) {
      // 获取交易对手全量
      this.props.dispatch({
        type: 'exchangeAgreement/queryCounterparty',
        payload: {
          value: value,
        },
      });
    }
  };

  //切换组合
  groupOnChange = (value) => {
    const {
      form: { getFieldValue },
    } = this.formGroupThis.props;
    //切换后清空页面
    this.resetPage();
    this.resetField(1);
    this.props.changeMasking(value);
    if (value) {
      let portfolioId = value.key;
      //获取持仓分析信息,把portfolioId和exchangeCode传到持仓组件
      let exchangeCode = getFieldValue('exchangeCode');
      let positionParameter = {
        portfolioId: portfolioId,
        exchangeCode: exchangeCode,
      };

      this.props.getConfigData('PositionAnalysis', positionParameter);

      //获取在途回购信息,把portfolioId和method传到在途回购组件

      let method = this.props.type == '1' ? '0' : '1';
      let repurchaseParameter = {
        portfolioId: portfolioId,
        method: method,
      };
      this.props.getConfigData('RepurchaseInfor', repurchaseParameter);

      //解开申报类型，交易市场，委托方向disabled
      this.setState({
        orderCategoryDisabled: false,
        exchangeCodeDisabled: false,
      });
    } else {
      //设置为disabled
      this.setState({
        disabled: true,
        orderCategoryDisabled: true,
        exchangeCodeDisabled: true,
        orderSideDisabled: true,
      });
    }
  };

  //切换交易所
  jysOnChange = (e) => {
    const {
      form: { getFieldValue },
    } = this.formGroupThis.props;
    //切换后清空页面
    this.resetPage();
    this.resetField(2);
    //控制必填
    this.changeFee('exchangecode', e ? e : undefined);
    if (e == '101') {
      this.setState({
        counterPartyperRequired: true,
      });
    } else {
      this.setState({
        counterPartyperRequired: false,
        counterPartyAccountDisabled: true,
        counterPartyorgDisabled: true,
      });
    }
    //向外抛出交易市场和组合重新获取持仓
    let portfolioId = getFieldValue('portfolioId');
    let exchangeCode = e;
    let positionParameter = {
      portfolioId: portfolioId,
      exchangeCode: exchangeCode,
    };
    this.props.getConfigData('PositionAnalysis', positionParameter);
    this.props.getConfigData('exchangeCode', exchangeCode);
  };

  //切换申报类型
  sblxOnChange = (e) => {
    //解开委托方向disabled
    this.setState({
      orderSideDisabled: false,
    });
    //申报类型不为成交申报时必填和disabled控制
    if (e == '1') {
      this.setState({
        originalOrderNumberRequired: false,
        originalOrderNumberDisabled: true,
        lendingFeeDisabled: true,
      });
    } else if (e == '2') {
      this.setState({
        originalOrderNumberRequired: true,
        originalOrderNumberDisabled: false,
        lendingFeeDisabled: true,
      });
    } else if (e == '3') {
      this.setState({
        originalOrderNumberRequired: true,
        originalOrderNumberDisabled: false,
        lendingFeeDisabled: false,
      });
    }
    //抛出申报类型
    this.props.getConfigData('orderCategory', e);
  };

  //委托方向改变
  wtfxOnChange = (e) => {
    const {
      form: { getFieldValue, setFieldsValue },
    } = this.formGroupThis.props;
    //切换后清空质押券和标的券
    this.props.resetPage();
    this.setState({
      totalMoney: null,
    });
    setFieldsValue({ lendingTotalMoney: '' });

    this.changeFee('price', undefined);
    //解开下面的disable
    this.setState({
      disabled: false,
    });
    this.changeFee('orderside', e ? e : undefined);
    if (e == '1') {
      this.setState(
        {
          totalMoney: this.props.totalMoney2,
        },
        () => {
          let lendingRate = getFieldValue('lendingRate');
          let totalMoney = this.state.totalMoney;
          let occupationDays = getFieldValue('occupationDays');
          this.calculationLendingFee(lendingRate, totalMoney, occupationDays);
        },
      );
      setFieldsValue({ lendingTotalMoney: this.props.totalMoney2 });
      this.changeFee('price', this.props.totalMoney2);
    }

    if (e == '2') {
      this.setState(
        {
          totalMoney: this.props.totalMoney2,
        },
        () => {
          let lendingRate = getFieldValue('lendingRate');
          let totalMoney = this.state.totalMoney;
          let occupationDays = getFieldValue('occupationDays');
          this.calculationLendingFee(lendingRate, totalMoney, occupationDays);
        },
      );
      setFieldsValue({ lendingTotalMoney: this.props.totalMoney2 });
      this.changeFee('price', this.props.totalMoney2);
    }
    //抛出委托方向
    this.props.getConfigData('orderSide', e);
  };

  //清算速度改变
  qssdOnChange = (e) => {
    const {
      form: { setFieldsValue, getFieldValue },
    } = this.formGroupThis.props;
    let lendingDays = getFieldValue('lendingDays');
    //设置首次结算日的值,如果有借贷天数要重新计算
    if (e == '1') {
      setFieldsValue({
        firstsettlementDate: moment(new Date()),
      });
      if (lendingDays && this.checkDay(lendingDays)) {
        this.calculationDate(moment(new Date()).format('YYYY-MM-DD'), lendingDays);
      }
    }
    if (e == '2') {
      setFieldsValue({
        firstsettlementDate: moment().add(1, 'day'),
      });
      if (lendingDays && this.checkDay(lendingDays)) {
        this.calculationDate(moment().add(1, 'day').format('YYYY-MM-DD'), lendingDays);
      }
    }
  };

  //借款天数改变
  jktsOnChange = (e) => {
    const {
      form: { setFieldsValue, getFieldValue },
    } = this.formGroupThis.props;
    let day = e.target.value;
    this.changeFee('timeLimit', day ? day : undefined);
    let firstsettlementDate = moment(getFieldValue('firstsettlementDate')).format('YYYY-MM-DD');
    if (this.checkDay(day)) {
      this.calculationDate(firstsettlementDate, day);
    }
  };

  //正则判断是否为不大于365的正整数
  checkDay = (day) => {
    const reg = /^([1-9]|[1-9][0-9]|[1-2][0-9][0-9]|[3][0-5][0-9]|(360|361|363|362|364|365))$/;
    const r = day.match(reg);
    if (r == null) {
      return false;
    } else {
      return true;
    }
  };

  //计算天数
  calculationDate = (date, day) => {
    const {
      form: { setFieldsValue, getFieldValue },
    } = this.formGroupThis.props;
    if (date && day) {
      this.props.dispatch({
        type: 'exchangeAgreement/calculation',
        payload: {
          repurchaseDays: day,
          firstSettlemenDate: date,
        },
        callback: (data) => {
          setFieldsValue({
            settlementDate: moment(data.settlementDate),
            occupationDays: data.occupationDays,
          });

          let lendingRate = getFieldValue('lendingRate');
          let totalMoney = this.state.totalMoney;
          let occupationDays = data.occupationDays;
          this.calculationLendingFee(lendingRate, totalMoney, occupationDays);
        },
      });
    }
  };

  //给父元素调用（指令下达），返回质押券信息
  getpledgeList = () => {
    const { user } = this.props;
    const {
      form: { validateFields },
    } = this.formGroupThis.props;
    let value = {};
    validateFields(
      [
        'productId',
        'portfolioId',
        'orderCategory',
        'exchangeCode',
        'orderSide',
        'originalOrderNumber',
        'counterParty',
        'counterPartyper',
        'counterPartyAccount',
        'counterPartyorg',
        'liquidationSpeed',
        'lendingDays',
        'occupationDays',
        'loanFaceValue',
        'lendingRate',
        'fee',
        'lendingFee',
        'firstsettlementType',
        'settlementType',
        'firstsettlementDate',
        'settlementDate',
        'pledgeExchange',
        'conflictreSolution',
        'creator',
        'remark',
        'investmentType',
      ],
      (err, fieldsValue) => {
        if (err) return;

        value = {
          pid: this.state.pid,
          portfolioId: fieldsValue.portfolioId,
          portfolioInfoId: fieldsValue.portfolioId,
          productId: fieldsValue.productId,
          type: 16,
          userId: localStorage.getItem('antd-pro-userId'),
          userName: user.currentUser.name,
          trade16: {
            portfolioId: fieldsValue.portfolioId,
            productId: fieldsValue.productId,
            orderCategory: fieldsValue.orderCategory,
            exchangeCode: fieldsValue.exchangeCode,
            orderSide: fieldsValue.orderSide,
            originalOrderNumber: fieldsValue.originalOrderNumber,
            counterParty: fieldsValue.counterParty,
            counterPartyper: fieldsValue.counterPartyper,
            counterPartyAccount: fieldsValue.counterPartyAccount,
            counterPartyorg: fieldsValue.counterPartyorg,
            liquidationSpeed: fieldsValue.liquidationSpeed,
            lendingDays: fieldsValue.lendingDays,
            occupationDays: fieldsValue.occupationDays,
            lendingeAmount: this.state.totalMoney,
            lendingRate: fieldsValue.lendingRate,
            lendingFee: fieldsValue.lendingFee,
            firstsettlementType: fieldsValue.firstsettlementType,
            settlementType: fieldsValue.settlementType,
            firstSettlemenDate: moment(fieldsValue.firstSettlemenDate).format('YYYY-MM-DD'),
            settlementDate: moment(fieldsValue.settlementDate).format('YYYY-MM-DD'),
            pledgeExchange: fieldsValue.pledgeExchange,
            conflictreSolution: fieldsValue.conflictreSolution,
            creator: fieldsValue.creator,
            remark: fieldsValue.remark,
            investmentType: fieldsValue.investmentType,
            fee: 0, // 费用计算逻辑未完全梳理清楚，后续用户有真正需求时再添加费用计算相关逻辑
          },
        };

        if (this.props.type == '2') {
          value.id = this.state.editId1;
          value.trade16.id = this.state.editId2;
        }
      },
    );

    return value;
  };

  //借贷面额改变
  jdmeOnChange = (e) => {
    const {
      from: { setFieldsValue },
    } = this.formGroupThis.props;
    this.setState({
      totalMoney: e.target.value,
    });
    setFieldsValue({ lendingTotalMoney: e.target.value });
    this.changeFee('price', e.target.value);
  };

  //借贷费率改
  jdflOnChange = (e) => {
    const {
      form: { getFieldValue },
    } = this.formGroupThis.props;
    //    const reg =  /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/;
    //    const r = e.match(reg);
    //    if(r==null) {
    //        return
    //    }
    if (e && e > 0) {
      let lendingRate = e;
      let totalMoney = this.state.totalMoney;
      let occupationDays = getFieldValue('occupationDays');
      this.calculationLendingFee(lendingRate, totalMoney, occupationDays);
    }
  };

  //借贷费用计算公式
  calculationLendingFee = (lendingRate, totalMoney, occupationDays) => {
    const {
      form: { setFieldsValue },
    } = this.formGroupThis.props;

    // 禁用时的计算公式：借贷费率*借贷面额*10000*实际占款天数/365
    if (lendingRate && totalMoney && occupationDays && this.state.lendingFeeDisabled == true) {
      setFieldsValue({
        lendingFee: Number(((Number(lendingRate) / 100) * Number(totalMoney) * Number(occupationDays)) / 365).toFixed(4),
      });
    }
  };

  render() {
    const { user, type } = this.props;

    return (
      <FormGroup
        dataSource={[
          {
            disabled: this.state.productGroupDisabled || this.state.reNewDataDisabled,
            initialValue: [
              this.state.formItem.productId ? this.state.formItem.productId : init.productId.initValue,
              this.state.formItem.portfolioId ? this.state.formItem.portfolioId : init.portfolioId.initValue,
            ],
            title: ['产品', '组合'],
            type: DATA_ENTRY.PRODUCTGROUPSEP,
            authority: 'write',
            multipleGroup: false,
            dataIndex: ['productId', 'portfolioId'],
            rules: [[{ required: init.productId.required, message: '请选择产品' }], [{ required: true, message: '请选择组合' }]],
            groupOnChange: (e) => {
              this.groupOnChange(e);
              this.changeFee('portfolioid', e?.key);
              this.props.portfolioCode(e ? e.info.portfolioCode : undefined); //向外抛出组合code
            },
            productOnChange: (e) => {
              this.changeFee('productId', e?.key);
              this.props.productCode(e ? e.info.portfolioCode : undefined); //向外抛出产品code
            },
            allowClear: false,
            exist: 1,
            span: 24,
            tradeModel: type == 1 ? ['BOOKKEEPING_MODE', 'COMMAND_MODE'] : undefined, //不包含估值解析和估值对接的产品
          },
          {
            title: '投资类型',
            dataIndex: 'investmentType',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.investmentType ? this.state.formItem.investmentType : init.investmentType.initValue,
            disabled: this.state.orderCategoryDisabled,
            dataSource: investmentTypeData,
            allowClear: true,
            rules: [{ required: false, message: '请选择' }],
            span: 12,
          },
          {
            title: '申报类型',
            dataIndex: 'orderCategory',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.orderCategory ? this.state.formItem.orderCategory : init.orderCategory.initValue,
            rules: [{ required: init.orderCategory.required, message: '请选择申报类型' }],
            disabled: this.state.orderCategoryDisabled,
            dataSource: this.state.orderCategoryData,
            onChange: (e) => this.sblxOnChange(e),
            span: 12,
          },
          {
            title: '交易市场',
            dataIndex: 'exchangeCode',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.exchangeCode ? this.state.formItem.exchangeCode : init.exchangeCode.initValue,
            rules: [{ required: init.exchangeCode.required, message: '请选择交易市场' }],
            disabled: this.state.exchangeCodeDisabled || this.state.reNewDataDisabled,
            dataSource: bondLending.exchange,
            onChange: (e) => this.jysOnChange(e),
            span: 12,
            onRef: (ref) => (this.formGroupThis = ref),
          },
          {
            title: '委托方向',
            dataIndex: 'orderSide',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.orderSide ? this.state.formItem.orderSide : init.orderSide.initValue,
            rules: [{ required: init.orderSide.required, message: '请选择委托方向' }],
            disabled: this.state.orderSideDisabled || this.state.reNewDataDisabled,
            dataSource: bondLending.orderSide,
            onChange: (e) => this.wtfxOnChange(e),
            span: 12,
          },
          {
            title: '原订单号',
            dataIndex: 'originalOrderNumber',
            type: DATA_ENTRY.INPUT,
            initialValue: this.state.formItem.originalOrderNumber ? this.state.formItem.originalOrderNumber : init.originalOrderNumber.initValue,
            rules: [{ required: this.state.originalOrderNumberRequired, message: '请选择原订单号' }],
            disabled: true,
            span: 12,
          },
          {
            dataIndex: 'counterParty',
            type: DATA_ENTRY.TRADINGCOMPANY,
            rules: [{ required: init.counterParty.required, message: '请选择交易对手' }],
            initialValue: this.state.formItem.counterParty ? this.state.formItem.counterParty : init.counterParty.initValue,
            multiple: false,
            disabled: this.state.disabled || this.state.reNewDataDisabled,
            placeholder: '请选择',
            span: 12,
            scenesType: type, //组件场景类型，用于详情时根据ID回填值
          },
          {
            title: '对手交易员',
            dataIndex: 'counterPartyper',
            type: DATA_ENTRY.INPUT,
            initialValue: this.state.formItem.counterPartyper ? this.state.formItem.counterPartyper : init.counterPartyper.initValue,
            rules: [{ required: this.state.counterPartyperRequired, message: '请输入对手交易员' }],
            disabled: this.state.disabled || this.state.reNewDataDisabled,
            span: 12,
          },
          {
            title: '交易对手账户',
            dataIndex: 'counterPartyAccount',
            type: DATA_ENTRY.INPUT,
            initialValue: this.state.formItem.counterPartyAccount ? this.state.formItem.counterPartyAccount : init.counterPartyAccount.initValue,
            rules: [{ required: this.state.counterPartyperRequired, message: '请输入对手交账户' }],
            disabled: this.state.disabled || this.setState.counterPartyAccountDisabled,
            span: 12,
          },
          {
            title: '交易对手单元',
            dataIndex: 'counterPartyorg',
            type: DATA_ENTRY.INPUT,
            initialValue: this.state.formItem.counterPartyorg ? this.state.formItem.counterPartyorg : init.counterPartyorg.initValue,
            rules: [{ required: this.state.counterPartyperRequired, message: '请输入对手交单元' }],
            disabled: this.state.disabled || this.setState.counterPartyorgDisabled,
            span: 12,
          },
          {
            title: '清算速度',
            dataIndex: 'liquidationSpeed',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.liquidationSpeed ? this.state.formItem.liquidationSpeed : init.liquidationSpeed.initValue,
            rules: [{ required: init.liquidationSpeed.required, message: '请输入清算速度' }],
            disabled: this.state.disabled || this.state.reNewDataDisabled,
            dataSource: bondLending.liquidationSpeed,
            onChange: (e) => this.qssdOnChange(e),
            span: 12,
          },
          {
            title: '借贷天数',
            dataIndex: 'lendingDays',
            type: DATA_ENTRY.INPUT,
            initialValue: this.state.formItem.lendingDays ? this.state.formItem.lendingDays : init.lendingDays.initValue,
            rules: [
              { required: init.lendingDays.required, message: '请输入借贷天数' },
              { pattern: /^([1-9]|[1-9][0-9]|[1-2][0-9][0-9]|[3][0-5][0-9]|(360|361|363|362|364|365))$/, message: '必须为不大于365的正整数' },
            ],
            validateTrigger: 'onBlur',
            disabled: this.state.disabled || this.state.reNewDataDisabled,
            onChange: (e) => this.jktsOnChange(e),
            suffix: '天',
            span: 12,
          },
          {
            title: '实际占款天数',
            dataIndex: 'occupationDays',
            type: DATA_ENTRY.INPUT,
            initialValue: this.state.formItem.occupationDays ? this.state.formItem.occupationDays : init.occupationDays.initValue,
            rules: [
              { required: init.occupationDays.required, message: '请输入实际占款天数' },
              { pattern: /^\+?[1-9]\d*$/, message: '实际占款天数必须为正整数' },
            ],
            validateTrigger: 'onBlur',
            disabled: true,
            suffix: '天',
            span: 12,
          },
          {
            title: '借贷面额',
            dataIndex: 'lendingTotalMoney',
            type: DATA_ENTRY.INPUT,
            value: this.state.totalMoney,
            disabled: true,
            suffix: '元',
            onChange: (e) => this.jdmeOnChange(e),
            span: 12,
          },
          {
            title: '借贷费率(%)',
            dataIndex: 'lendingRate',
            type: DATA_ENTRY.INPUTNUMBER,
            initialValue: this.state.formItem.lendingRate ? this.state.formItem.lendingRate : init.lendingRate.initValue,
            rules: [
              { required: true, message: '请输入借贷费率' },
              { pattern: /^(?!(0[0-9]{0,}$))[0-9]{1,}[.]{0,}[0-9]{0,}$/, message: '借贷费率大于0' },
            ],
            validateTrigger: 'onBlur',
            disabled: this.state.disabled,
            precision: 4,
            onChange: (e) => this.jdflOnChange(e),
            span: 12,
          },
          {
            dataIndex: 'lendingFee',
            type: DATA_ENTRY.INPUTNUMBER,
            disabled: this.state.disabled || this.state.lendingFeeDisabled,
            initialValue: this.state.formItem.lendingFee ? this.state.formItem.lendingFee : init.lendingFee.initValue,
            title: '借贷费用',
            splitStyle: true,
            unit: '元',
            rules: [{ required: init.lendingFee.required, message: '请输入借贷费用' }],
          },
          {
            title: '首次结算方式',
            dataIndex: 'firstsettlementType',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.firstsettlementType ? this.state.formItem.firstsettlementType : init.firstsettlementType.initValue,
            rules: [{ required: init.firstsettlementType.required, message: '请输入首次结算方式' }],
            disabled: true,
            dataSource: bondLending.firstsettlementType,
            span: 12,
          },
          {
            title: '到期结算方式',
            dataIndex: 'settlementType',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.settlementType ? this.state.formItem.settlementType : init.settlementType.initValue,
            rules: [{ required: init.settlementType.required, message: '请输入到期结算方式' }],
            disabled: true,
            dataSource: bondLending.settlementType,
            span: 12,
          },
          {
            title: '首期结算日',
            type: DATA_ENTRY.SINGLEDATE,
            dataIndex: 'firstsettlementDate',
            initialValue: this.state.formItem.firstsettlementDate ? moment(this.state.formItem.firstsettlementDate) : this.state.firstsettlementDate,
            rules: [{ required: init.firstsettlementDate.required, message: '请输入首次结算日' }],
            disabled: true,
            onChange: (e) => this.sqjsrOnChange(e),
            span: 12,
          },
          {
            title: '到期结算日',
            type: DATA_ENTRY.SINGLEDATE,
            dataIndex: 'settlementDate',
            initialValue: this.state.formItem.settlementDate ? moment(this.state.formItem.settlementDate) : null,
            rules: [{ required: init.settlementDate.required, message: '请输入到期结算日' }],
            disabled: true,
            onChange: (e) => this.dqjsrOnChange(e),
            span: 12,
          },
          {
            title: '质押券置换安排',
            dataIndex: 'pledgeExchange',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.pledgeExchange ? this.state.formItem.pledgeExchange : init.pledgeExchange.initValue,
            rules: [{ required: init.pledgeExchange.required, message: '请输入质押券置换安排' }],
            disabled: this.state.disabled || this.state.reNewDataDisabled,
            dataSource: bondLending.pledgeExchange,
            span: 12,
          },
          {
            title: '争议解决方式',
            dataIndex: 'conflictreSolution',
            type: DATA_ENTRY.SELECT,
            initialValue: this.state.formItem.conflictreSolution ? this.state.formItem.conflictreSolution : init.conflictreSolution.initValue,
            rules: [{ required: init.conflictreSolution.required, message: '请输入争议解决方式' }],
            disabled: this.state.disabled || this.state.reNewDataDisabled,
            dataSource: bondLending.conflictreSolution,
            span: 12,
          },
          //  {
          //      title: '费用',
          //      dataIndex: 'fee',
          //      placeholder: "请输入",
          //      type: DATA_ENTRY.INPUTNUMBER,
          //      min: 0,
          //      precision: 2,
          //      initialValue: this.state.formItem.fee ? this.state.formItem.fee : '',
          //      splitStyle: true,
          //      disabled: this.props.type == '3' || this.props.type == '4' ? true : false,
          //      unit: '元',
          //      span: 12
          //  },
          {
            title: '下达人',
            dataIndex: 'creator',
            type: DATA_ENTRY.INPUT,
            initialValue: user.currentUser.name,
            rules: [{ required: init.creator.required, message: '请输入下达人' }],
            disabled: true,
            span: 12,
          },

          {
            dataIndex: 'remark',
            type: DATA_ENTRY.INPUT,
            title: '备注',
            disabled: this.state.disabled,
            initialValue: this.state.formItem.remark ? this.state.formItem.remark : init.remark.initValue,
            rules: [{ required: init.remark.required, message: '请输入备注' }],
            placeholder: '请输入',
            showTextArea: true,
            autosize: { minRows: 2, maxRows: 2 },
            span: 24,
          },
        ]}
        autoLayout={false}
      />
    );
  }
}
